package swingSupport;

import com.jgoodies.plaf.LookUtils;
import com.jgoodies.plaf.plastic.Plastic3DLookAndFeel;
import com.jgoodies.plaf.plastic.PlasticXPLookAndFeel;
import com.jgoodies.plaf.plastic.theme.DesertBlue;
import com.jgoodies.plaf.plastic.theme.DesertYellow;
import com.jgoodies.plaf.plastic.theme.ExperienceBlue;
import com.jgoodies.plaf.plastic.theme.InvertedColorTheme;
import com.jgoodies.plaf.plastic.theme.Silver;
import com.jgoodies.plaf.plastic.theme.SkyBlue;
import com.jgoodies.plaf.plastic.theme.SkyYellow;
import com.jgoodies.plaf.windows.ExtWindowsLookAndFeel;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
//import javax.swing.UIManager.LookAndFeelInfo;

public class LaFSupport {

    private final static Logger logger = Logger.getLogger(LaFSupport.class.getName());

    public static void setLaF() {
        //setStandardLaf();
        tryJGoodiesLAF();        
    }

    private static void tryJGoodiesLAF() {

        /*
         The class must be one of the following: 
         com.jgoodies.plaf.windows.ExtWindowsLookAndFeel 
         com.jgoodies.plaf.plastic.PlasticLookAndFeel 
         com.jgoodies.plaf.plastic.Plastic3DLookAndFeel 
         com.jgoodies.plaf.plastic.PlasticXPLookAndFeel 
         The Plastic themes use a default color scheme that is appropriate for your operating system. 
         * However a method setMyCurrentTheme is provided that allows you to override this. 
         * For example: 
         PlasticLookAndFeel.setMyCurrentTheme(new DesertBlue());  
         */

        UIManager.put("ClassLoader", LookUtils.class.getClassLoader());
        try {
            //PlasticXPLookAndFeel
            //ExtWindowsLookAndFeel laf = new ExtWindowsLookAndFeel();
            Plastic3DLookAndFeel laf = new Plastic3DLookAndFeel();
            // laf = new PlasticXPLookAndFeel();  
            Plastic3DLookAndFeel.set3DEnabled(true);
            Plastic3DLookAndFeel.setMyCurrentTheme(new ExperienceBlue());
            UIManager.setLookAndFeel(laf);
            //Plastic3DLookAndFeel.set3DEnabled(true);
            //Plastic3DLookAndFeel.setMyCurrentTheme(new DesertYellow());
            //Plastic3DLookAndFeel.setMyCurrentTheme(new DesertBlue());
        } catch (Exception e) {
            logger.warning("UIManager kann jgoodies Plastic3DLookAndFeel nicht als LAF setzen- Default LaF wird verwendet");
        }

        //PlasticLookAndFeel.setMyCurrentTheme(new DesertBlue());

    }

    private static void setStandardLaf() {
        //Look and Feels
        String LaF_Metal = "Metal", LaF_Nimbus = "Nimbus",
                LaF_CDE_Motif = "CDE/Motif", LaF_Windows = "Windows",
                LaF_Windwos_Classic = "Windows Classic";


        try {
            boolean isFoundLaF = false;
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if (LaF_Nimbus.equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    logger.finest("finest - Look and Feel Nimbus successfully set");
                    isFoundLaF = true;
                    break;
                }
            }
            if (!isFoundLaF) {
                logger.warning("NimbusLookAndFeel nicht installiert - Default LaF wird verwendet");
            }
        } catch (Exception e) {
            logger.warning("NimbusLookAndFeel nicht installiert - Default LaF wird verwendet");
        }

    }
}
